import { regExgr } from "./regs";

export default {
    model (vm, value, node) {
        const cb = () => node.value = vm.$data[value];
        node.addEventListener('input', () => {
            vm.$data[value] = node.value
        }, false);
        node.removeAttribute('v-model');
        vm.dep.add(value, cb);
        cb();
    },
    text (vm, text, node) {
        node.textContent = text.replace(regExgr, (_node, key) => {
            const cb = () => node.textContent = vm.$data[key];
            key = key.trim();
            vm.dep.add(key, cb);
            return vm.$data[key]
        })
    }
}